home *** CD-ROM | disk | FTP | other *** search
- Path: inforamp.net!ts6-06
- From: rmorin@inforamp.net (Randy Charles Morin)
- Newsgroups: comp.lang.c++
- Subject: Re: help with array initialization
- Date: Sat, 09 Mar 96 19:28:57 GMT
- Organization: MiddleWorld SoftWare
- Message-ID: <4hsm66$rsm@sam.inforamp.net>
- References: <31409BCC.2FCD@ovnet.com>
- NNTP-Posting-Host: ts6-06.tor.inforamp.net
- X-Newsreader: News Xpress Version 1.0 Beta #4
-
- In article <31409BCC.2FCD@ovnet.com>,
- Michael Wallace <mjwpop@ovnet.com> wrote:
- >I am a student learning c++ and have a question concerning initialization
- >of arrays. The textbook I am using (C++, How to program) says that you
- >can initialize arrays in this manner - int array[100]={0}; anytime.
- >However, trying to compile this with Borland Turbo C++ 4.5 gives an
- >error, it only allows that type of initialization if the variable is
- >declared static. I have another reference manual (C++, The Complete
- >Reference) and as far as I can find, it doesn't say which is correct. If
- >someone would please tell me if the textbook or the comipiler is correct?
-
- I compiled and ran...
- -----------------------------------
- int main()
- {
- int array[100]={0};
- array[0]=1;
- return array[0];
- };
- -----------------------------------
- ..successfully with Borland 4.5 and Borland 4.52.
- I also tried...
- ------------------------------------
- int main()
- {
- static int array[100]={0};
- array[0]=1;
- return array[0];
- };
- -------------------------------------
- ..without any problems.
- Just thought you'd want to know I couldn't reproduce the problem.
-
- Agrivar
-